package com.stock.vo;

import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

@Data
public class ResultVo {

    @ApiModelProperty("状态")
    private Integer status;

    @ApiModelProperty("数据")
    private Object data;

    @ApiModelProperty("信息")
    private String message;

    public static ResultVo success(Object data, String message) {
        ResultVo resultVo = new ResultVo();
        resultVo.setStatus(200);
        resultVo.setData(data);
        resultVo.setMessage(message);  // 设置成功消息
        return resultVo;
    }

    public static ResultVo success(Object data) {
        return success(data, "操作成功");
    }

    public static ResultVo error(String message) {
        ResultVo resultVo = new ResultVo();
        resultVo.setStatus(500);
        resultVo.setMessage(message);
        resultVo.setData(null);  // 设置 null 数据，确保结构统一
        return resultVo;
    }

}
